<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script src="js/jquery.js"></script>
  <title>投票</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      font-size: 14px;
      line-height: 1.42857143;
      box-sizing: border-box;
    }
    
    .hide {
      display: none;
    }
    
    #create{
        width: 600px;
        padding: 15px 20px;
    }
    .form-group {
      margin-bottom: 15px;
    }
    
    .form-group::after {
      content: '';
      display: block;
      width: 0;
      height: 0;
      clear: both;
      visibility: hidden;
    }
    
    .control-label {
      float: left;
      width: 140px;
      margin-top: 7px;
      margin-right: 10px;
      text-align: right;
    }
    
    .control-wrap {
      float: left;
    }
    
    .options {
      position: relative;
      margin-bottom: 10px;
    }
    
    .del {
      position: absolute;
      top: 10px;
      right: -30px;
      color: red;
    }
    
    .form-control {
      display: block;
      width: 100%;
      height: 34px;
      padding: 6px 12px;
      font-size: 14px;
      line-height: 1.42857143;
      color: #555;
      background-color: #fff;
      background-image: none;
      border: 1px solid #ccc;
      border-radius: 4px;
      -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
      box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
      -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
      -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
      transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
    }
    
    .vote-type,
    .vote-type1 {
      margin-top: 10px;
    }
  </style>
</head>

<body>

  <div id="create">
    <div class="form-group">
      <label class="control-label">投票主题:</label>
      <div class="control-wrap">
        <textarea class="form-control"></textarea>
      </div>
    </div>
    <div class="form-group">
      <label class="control-label">投票选项:</label>
      <div class="control-wrap">
        <div class="options">
          <input type="text" class="form-control" placeholder="选项1" />
        </div>
        <div class="options">
          <input type="text" class="form-control" placeholder="选项2" />
        </div>
        <div class="options">
          <input type="text" class="form-control" placeholder="选项3" />
          <div class="del">删除</div>
        </div>
        <div class="add" id="addOption">+添加选项</div>
      </div>
    </div>
    <div class="form-group">
      <label class="control-label">选择模式:</label>
      <div class="control-wrap">
        <input type="radio" name="type" class="vote-type" value="0" checked /> 单选
        <input type="radio" name="type" class="vote-type" value="1" /> 多选
      </div>
    </div>
    <div class="form-group">
      <label class="control-label">截止时间:</label>
      <div class="control-wrap">
        <input type="text" class="form-control" id="endTime" />
      </div>
    </div>
    <div class="form-group">
      <label class="control-label">投票隐私:</label>
      <div class="control-wrap">
        <input type="radio" name="type1" class="vote-type1" value="0" checked /> 公开
        <input type="radio" name="type1" class="vote-type1" value="1" /> 匿名
      </div>
    </div>
    <div class="form-group">
        <a href="javascript:;">发布</a>
    </div>
  </div>

  <script>
    // add
    $('#addOption').on('click', function() {
      var idx = parseInt($('.options').length) + 1;
      var html = '';
      html += '<div class="options">';
      html += ' <input type="text" class="form-control" placeholder="选项' + idx + '" />';
      html += '  <div class="del">删除</div>';
      html += '</div>';

      $('#addOption').before(html);
    })

    // del
    $('body').on('click', '.del', function() {
      $(this).closest('.options').remove();
    })
  </script>
</body>

</html>